<!--
 * @description: 
 * @Date: 2022-11-02 21:36:32
 * @LastEditTime: 2022-11-09 19:37:15
-->
<template>
  <div class="manager-setting">
    <el-form v-model="formData" label-position="top">
      <h2>文件服务器配置</h2>
      <el-form-item label="文件服务地址">
        <el-input v-model="formData.upload" placeholder="文件上传服务器地址"></el-input>
      </el-form-item>
      <el-form-item label="资源cdn域名">
        <el-input v-model="formData.assets_host" placeholder="文件cdn域名"></el-input>
      </el-form-item>
      <h2>华为云 云储存方案</h2>
      <el-form-item label="华为云AK">
        <el-input
          type="password"
          show-password
          v-model="formData.huawei_ak"
          placeholder="华为云AK"
        ></el-input>
      </el-form-item>
      <el-form-item label="华为云SK">
        <el-input
          type="password"
          show-password
          v-model="formData.huawei_sk"
          placeholder="华为云SK"
        ></el-input>
      </el-form-item>
      <el-form-item label="华为云OBS储存桶名称">
        <el-input
          v-model="formData.huawei_bucket"
          placeholder="请输入华为云OBS储存桶名称"
        ></el-input>
      </el-form-item>
      <el-form-item label="华为云OBS桶endpoint">
        <el-input
          type="password"
          show-password
          v-model="formData.huawei_endpoint"
          placeholder="请输入华为云OBS桶endpoint"
        ></el-input>
      </el-form-item>
      <h2>邮件SMTP服务器</h2>
      <el-form-item label="SMTP HOST">
        <el-input
          type="password"
          show-password
          v-model="formData.smtp_host"
          placeholder="有件服务器地址"
        ></el-input>
      </el-form-item>
      <el-form-item label="邮箱账号">
        <el-input v-model="formData.smtp_email" placeholder="发件人邮箱"></el-input>
      </el-form-item>
      <el-form-item label="邮箱授权码/密码">
        <el-input
          type="password"
          show-password
          v-model="formData.smtp_password"
          placeholder="授权码/密码"
        ></el-input>
      </el-form-item>
      <h2>其他信息配置</h2>
      <el-form-item label="站点联系邮箱">
        <el-input v-model="formData.email" placeholder="联系客服邮箱"></el-input>
      </el-form-item>
      <el-form-item label="默认壁纸">
        <el-input
          v-model="formData.backgroundImage"
          placeholder="请设置网站默认壁纸"
        ></el-input>
      </el-form-item>
      <el-button type="primary" @click="update">保存配置文件</el-button>
    </el-form>
  </div>
</template>
<script setup>
import { ElMessage } from "element-plus";
import { ref } from "vue";
import ajax from "../../util/ajax";
import sm from "../../util/sm2";
const formData = ref({});
const update = () => {
  ajax({
    url: "setting/saveSetting",
    method: "post",
    data: {
      form: sm.encode(JSON.stringify(formData.value)),
    },
  }).then((el) => {
    if (el.code == 1) {
      ElMessage.success("保存成功");
      start();
    }
  });
};
const start = () => {
  ajax({
    url: "setting/getSetting",
    method: "get",
  }).then((el) => {
    if (el.code == 1) {
      formData.value = JSON.parse(sm.decode(el.data));
    }
  });
};
start();
</script>
<style lang="less">
.manager-setting {
}
</style>
